<?
ob_start();
session_start();
		if(trim($HTTP_SESSION_VARS['user_login']) == ""){
			echo"
			<tr>
			 <td align=center colspan=3>
			 <br><br><br>".$_SESSION['user_login']."
				Maaf, Anda tidak bisa mengakses halaman ini, Anda harus login terlebih dahulu ... <br><br>
				[ <a href='$path/index.php'>silahkan login</a> ]
			 </td>
			</tr>
			";
			exit();
		}
// detail data
include("config.php");
include("function.php");
//include_once("tes.php");
$nik	= $HTTP_GET_VARS['nik'];
$log_id	= $HTTP_GET_VARS['log_id'];
// data pribadi
$sql	= "SELECT NIK, A.Nama, TempatLahir, CONVERT(CHAR(12),Tgl_Lahir, 103) TglLahir, B.nama StatusKawin, C.nama Agama, WargaNegara, NoTelepon, Email, Alamat  FROM karyawan A, VStatusKawin B, VAgama C WHERE A.status=B.kode and A.agama=C.kode AND A.NIK='$nik'";
$result	= mssql_query($sql,$conn);
$rows	= mssql_fetch_array($result);

?>
<title>CV Online</title>
<style type="text/css">
body{
	font-size:medium;
}

table{
	font-family: verdana;
	font-size:12px;
	color:	#000000
}

.cell{
	color: #000000;
	background-color:#FFFFFF;
}

.cell2{
	background-color:#CCCCCC;
}

.title{
	font-size:16px; font-weight:bold; background-color:#EFEFEF;
	height:35px; vertical-align:top; font-family: arial, tahoma, verdana;
}

</style>
<link rel="stylesheet" type="text/css" href="../style/print.css" media="print" />
<table width="100%" border="0">
<?
if($HTTP_GET_VARS['versi'] == "msword")
{
	// insert into log download this file
	mssql_query("INSERT INTO S_Log_Detail_CVOnline (NIK, rand_num, date_created) VALUES ('$nik','$log_id','".date("Y-m-d H:i:s")."')",$conn);
}
else{
	 echo'<tr>
	  <td colspan="2" class="print_ignore" align="left">[ <a href="#" onclick="Javascript:self.print();" style="text-decoration:none; color:#000066;"><b>Cetak</b></a> | <a href="'.$PHP_SELF.'?versi=msword&amp;nik='.$nik.'" style="text-decoration:none; color:#000066;" ><b>Simpan ke MS-Word</b></a> ]</td>
	 </tr>';
}
?>
 <tr>
  <td colspan="2">
  </td>
 </tr>
 <tr>
  <td colspan="2">&nbsp;</td>
 </tr>
 <tr>
  <td colspan="2" style="border-bottom:solid 1px #000000;"><img src="../images/logo_ptsi.jpg" /></td>
 </tr>
 <tr>
  <td colspan="2" style="font-size:18px;" align="center"><b><br />CURRICULUM VITAE</b><br /><br />
  </td>
 </tr>
 <tr>
  <td colspan="2" class="title">&nbsp;<?=strtoupper($rows[Nama])?>
   <br /><br />
  </td>
 </tr>
 <tr>
  <td>&nbsp;Tempat, Tanggal Lahir</td>
  <td>: <?=$rows[TempatLahir]?>, <?=$rows[TglLahir]?></td>
 </tr>
 <tr>
  <td>&nbsp;Jenis Kelamin</td>
  <td>:
  <?
  	if($rows[JKel] == 0){
		echo"Pria";
	}
	elseif($rows[JKel] == 1){
		echo"Wanita";
	}
  ?>
  </td>
 </tr>
 <tr>
  <td>&nbsp;Status Pernikahan</td>
  <td>: <?=$rows[StatusKawin]?></td>
 </tr>
 <tr>
  <td>&nbsp;Agama</td>
  <td>: <?=$rows[Agama]?></td>
 </tr>
 <tr>
  <td>&nbsp;Warga Negara</td>
  <td>: 
  <?
  	$sWN = mssql_query("select Remarks from mstdata where groupcode='bhs' and Code='$rows[WargaNegara]'",$conn);
	$rWN = mssql_fetch_array($sWN);
	echo"$rWN[0]";
  ?></td>
 </tr>
 <tr>
  <td valign="top">&nbsp;Alamat</td>
  <td valign="top">: <?=$rows[Alamat]?></td>
 </tr>
 <tr>
  <td>&nbsp;Telepon/HP</td>
  <td>: <?=$rows[NoTelepon]?></td>
 </tr>
 <tr>
  <td>&nbsp;Email</td>
  <td>: <?=$rows[Email]?></td>
 </tr>
 <tr>
  <td colspan="2">&nbsp;</td>
 </tr>
 <tr>
  <td colspan="2" class="title">&nbsp;EDUCATION</td>
 </tr>
 <tr>
  <td colspan="2">
  <?
  	$sqlP = mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY Sampai) AS No, NIK,NamaKampus,fakultas, jurusan, year(Sampai) tahun from pendidikan A, MstPendidikan B
where A.Pend_ID=B.Pend_ID AND NIK='$nik' ORDER BY Sampai ASC",$conn);
  ?>
	<table border="0" cellpadding="1" cellspacing="1" width="80%">
	<?
	while($rowP = mssql_fetch_array($sqlP)){
		echo"<tr>
			  <td width=17 align=right valign=top>$rowP[No].&nbsp;</td>
	  		  <td valign=top width=400>$rowP[NamaKampus], Fakultas $rowP[fakultas], Jurusan $rowP[jurusan] </td>
			  <td valign=top width=30>$rowP[tahun]</td>
	 		 </tr>";
	}
	?>
	</table>
 </td>
 </tr>
 <tr>
  <td colspan="2">&nbsp;</td>
 </tr>
 <tr>
  <td colspan="2" class="title">
  TRAINING / COURSE
  </td>
 </tr>
 <tr>
 <td colspan="2" align="left">
  <table border="0" cellpadding="0" cellspacing="1" width="80%">
<?
// data kursus
	$sqlKur	 = mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY Sampai) as No, Program, Penyelenggara, Tempat, CONVERT(CHAR(12), Dari, 103) tgl_dari, CONVERT(CHAR(12), Sampai, 103) tgl_sampai, YEAR(Sampai) tahun, NoSertifikat, CONVERT(CHAR(12), TglSertifikat, 103) tgl_sertifikat, Sertifikat, IkatanDinas, CONVERT(CHAR(12), AwalIkatan, 103) awal_ikatan, CONVERT(CHAR(12), AkhirIkatan, 103) akhir_ikatan FROM KURSUS WHERE NIK='$nik' ORDER BY Sampai ASC",$conn);
	
	$sqlKurCnt = mssql_num_rows($sqlKur);
	if($sqlKurCnt > 0){
		while($rowKur	= mssql_fetch_array($sqlKur)){
		echo"
		 <tr valign=top>
		  <td width=10 align=right valign=top><b>$rowKur[No].</b>&nbsp;</td>
		  <td width=220 valign=top><b>$rowKur[Program]</b></td>
		  <td width=160 valign=top>$rowKur[Penyelenggara]</td>
		  <td width=20 valign=top>$rowKur[tahun]</td>
		 </tr>
		";
		} 
	}
	else
	{
		echo"<tr class=cell><td align=center colspan=20>--- TIDAK ADA DATA ---</td></tr>";
	}
?>
   </table>
  </td>
 </tr>
 <tr>
  <td colspan="2">&nbsp;</td>
 </tr>
 <tr>
  <td colspan="2" class="title">
  PROFESIONAL CERTIFICATES
  </td>
 </tr>
 <tr>
  <td colspan="2">
  <table border="0" cellpadding="1" cellspacing="1" width="80%">
<?
// data sertifikasi profesi
	$sqlKur3	 = mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY Cert_Date) as No, *, year(Cert_Date) tgl_sertifikat, CONVERT(CHAR(12), Cert_Date_Exp, 103) tgl_kadaluarsa FROM MK_Certification WHERE NIK='$nik' ORDER BY Cert_Date ASC",$conn);
	
	$sqlKurCnt3 = mssql_num_rows($sqlKur3);
	if($sqlKurCnt3 > 0){
		while($rowKur3	= mssql_fetch_array($sqlKur3)){
		echo"
		 <tr valign=top>
		  <td width=10 align=right valign=top>&nbsp;</td>
		  <td width=220 valign=top><b>$rowKur3[Cert_Name]</b></td>
		  <td width=200 valign=top>$rowKur3[tgl_sertifikat]</td>
		 </tr>
		";
		} 
	}
	else
	{
		echo"<tr class=cell><td align=center colspan=20>--- TIDAK ADA DATA ---</td></tr>";
	}
?>
   </table>
  </td>
 </tr>
 <tr>
  <td colspan="2">&nbsp;</td>
 </tr>
 <tr>
  <td colspan="2" class="title">
  WORK EXPERIENCES
  </td>
 </tr>
 <tr>
  <td colspan="2">
  <table border="0" cellpadding="1" cellspacing="1">
<?
// data pengalaman kerja
	$resPeng	= mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY sampai) as No, instansi, jabatan, year(sampai) end_year, scope_of_works FROM Karir WHERE NIK='$nik' ORDER BY sampai ASC ",$conn);
	$SqlPengCnt = mssql_num_rows($resPeng);
	if($SqlPengCnt > 0){
		while($rowPeng	= mssql_fetch_array($resPeng)){
		echo"
		 <tr class=cell valign=top>
		  <td colspan=2><b>".strtoupper($rowPeng[instansi])." ( $rowPeng[end_year] )</b></td>
		 </tr>
		 <tr height=30>
		  <td width=20>&nbsp;</td>
		  <td><i><b>Position: $rowPeng[jabatan]</b></i></td>
		 </tr>
		 <tr height=30>
		  <td width=20>&nbsp;</td>
		  <td><i><b>Scope of works: </b></i></td>
		 </tr>
		 <tr>
		  <td width=20>&nbsp;</td>
		  <td>$rowPeng[scope_of_works]</i></td>
		 </tr>
		 <tr>
		  <td colspan=2>&nbsp;</td>
		 </tr>
		";
		} 
		echo"
		
		";
	}
	else{
		echo"<tr class=cell><td align=center colspan=20>--- TIDAK ADA DATA ---</td></tr>";
	}
?>
   </table>
  </td>
 </tr>
 <tr>
  <td colspan="2">&nbsp;</td>
 </tr>
 <tr>
  <td colspan="2" class="title">
  PROJECT EXPERIENCES
  </td>
 </tr>
 <tr>
  <td colspan="2">&nbsp;</td>
 </tr>
 <tr>
 <td colspan="2">
 <table border="0" cellpadding="1" cellspacing="1" width="80%">
<?
	$TR = mssql_query("SELECT NIK, seqno, year(track_start) mulai, year(track_end) akhir, project, job_desc from mk_trackrecords WHERE NIK='".$nik."' AND (aktif = NULL OR aktif='A') order by seqno desc", $conn);
	while($rtr = mssql_fetch_array($TR)){
		echo"
		<tr>
		 <td colspan=2><b>".strtoupper($rtr[project])."</b></td>
		 <td width=55>$rtr[akhir]</td>
		</tr>
		<tr>
		 <td width=2>&nbsp;</td>
		 <td>$rtr[job_desc]</td>
		</tr>
		<tr>
		 <td colspan=2>&nbsp;</td>
		</tr>
		";
	}
?>
</table>
</td>
 </tr>
 </table>

<?
if($HTTP_GET_VARS['versi'] == "msword")
{
	header('Content-type: application/msword');
	header("Content-Disposition: attachment; filename=$nik"."_$rows[Nama]".".doc");
	header("Pragma: no-cache");
	header("Expires: 0");
}
else{

}
?>